using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;
using System.IO;

namespace SPWebPartManager_ControlAdapter
{
    class SPWebPartManager_ControlAdapterFeatureReceiver : SPFeatureReceiver
    {
        
        public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            SPWebApplication webApplication = properties.Feature.Parent as SPWebApplication;
            if (webApplication == null) return;

            SPWebPartManager_ControlAdapterJobDefinition job = new SPWebPartManager_ControlAdapterJobDefinition(SPWebPartManager_ControlAdapterJobDefinition.JobName, webApplication);
            job.Installing = true;
            job.Schedule = new SPOneTimeSchedule(DateTime.Now);
            job.Update();
        }

        public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
        {
            SPWebApplication webApplication = properties.Feature.Parent as SPWebApplication;
            if (webApplication == null) return;

            SPWebPartManager_ControlAdapterJobDefinition job = new SPWebPartManager_ControlAdapterJobDefinition(SPWebPartManager_ControlAdapterJobDefinition.JobName, webApplication);
            job.Installing = false;
            job.Schedule = new SPOneTimeSchedule(DateTime.Now);
            job.Update();
        }

        public override void FeatureInstalled(SPFeatureReceiverProperties properties)
        {
            
        }

        public override void FeatureUninstalling(SPFeatureReceiverProperties properties)
        {
            
        }
    }
}
